:root {
    --bg: #0d0d14;
    --card: #13131f;
    --border: #1e1e30;
    --yellow: #f5c842;
    --blue: #4fa8ff;
    --green: #4dffb0;
    --pink: #ff6b9d;
    --purple: #b87aff;
    --orange: #ff9f4a;
    --text: #e8e8f0;
    --muted: #7070a0;
    --sidebar-w: 260px;
  }

  section {
  margin-left: auto;
  margin-right: auto;
}

  * { box-sizing: border-box; margin: 0; padding: 0; }

  html { scroll-behavior: smooth; }

  body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Syne', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
  }

  body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
      linear-gradient(rgba(79,168,255,0.04) 1px, transparent 1px),
      linear-gradient(90deg, rgba(79,168,255,0.04) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: 0;
  }

  /* ===== TOP NAV ===== */
  nav.topnav {
    position: fixed; top: 0; left: 0; right: 0; z-index: 200;
    background: rgba(13,13,20,0.92); backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border); padding: 0 24px;
    height: 56px; display: flex; align-items: center; justify-content: space-between;
  }
  .nav-logo { font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 15px; color: var(--yellow); text-decoration: none; white-space: nowrap; }
  .nav-logo span { color: var(--muted); }
  .nav-right { display: flex; align-items: center; gap: 20px; }
  .nav-links { display: flex; gap: 24px; list-style: none; }
  .nav-links a { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--muted); text-decoration: none; letter-spacing: 1px; transition: color 0.2s; }
  .nav-links a:hover { color: var(--text); }
  .hamburger { display: none; flex-direction: column; gap: 5px; cursor: pointer; padding: 6px; background: none; border: 1px solid var(--border); border-radius: 8px; }
  .hamburger span { display: block; width: 20px; height: 2px; background: var(--muted); border-radius: 2px; }
  @media (max-width: 900px) { .nav-links { display: none; } .hamburger { display: flex; } }

  /* ===== LAYOUT ===== */
  .layout { display: flex; padding-top: 56px; min-height: 100vh; }

  /* ===== SIDEBAR ===== */
  .sidebar {
    position: fixed; top: 56px; left: 0; width: var(--sidebar-w);
    height: calc(100vh - 56px); overflow-y: auto;
    background: rgba(13,13,20,0.97); border-right: 1px solid var(--border);
    padding: 20px 0 40px; z-index: 100; transition: transform 0.3s ease;
  }
  .sidebar::-webkit-scrollbar { width: 3px; }
  .sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
  .sidebar-back { display: flex; align-items: center; gap: 8px; margin: 0 14px 16px; padding: 9px 14px; background: rgba(255,255,255,0.04); border: 1px solid var(--border); border-radius: 10px; font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--muted); text-decoration: none; transition: border-color 0.2s, color 0.2s, background 0.2s; }
  .sidebar-back:hover { border-color: var(--yellow); color: var(--yellow); background: rgba(245,200,66,0.06); }
  .sidebar-back-arrow { font-size: 14px; }
  .sidebar-divider { height: 1px; background: var(--border); margin: 10px 16px; }
  .sidebar-section-label { font-family: 'JetBrains Mono', monospace; font-size: 9px; letter-spacing: 3px; text-transform: uppercase; color: var(--muted); padding: 0 16px; margin-bottom: 5px; margin-top: 16px; }
  .sidebar-link { display: flex; align-items: center; gap: 9px; padding: 8px 16px; font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--muted); text-decoration: none; border-left: 2px solid transparent; transition: color 0.2s, background 0.2s, border-left-color 0.2s; }
  .sidebar-link:hover { color: var(--text); background: rgba(255,255,255,0.03); border-left-color: var(--border); }
  .sidebar-link.active { color: var(--blue); background: rgba(79,168,255,0.05); border-left-color: var(--blue); }
  .s-icon { font-size: 13px; width: 16px; text-align: center; flex-shrink: 0; }
  .s-badge { margin-left: auto; font-size: 9px; padding: 1px 5px; border-radius: 8px; background: rgba(79,168,255,0.12); color: var(--blue); }
  .sidebar-overlay { display: none; position: fixed; inset: 0; top: 56px; background: rgba(0,0,0,0.6); z-index: 99; }
  @media (max-width: 900px) { .sidebar { transform: translateX(-100%); } .sidebar.open { transform: translateX(0); } .sidebar-overlay.open { display: block; } }

  /* ===== MAIN ===== */
  .main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; position: relative; z-index: 1; }
  @media (max-width: 900px) { .main { margin-left: 0; } }

  /* ===== PROGRESS BAR ===== */
  .progress-bar { position: fixed; top: 56px; left: var(--sidebar-w); right: 0; height: 2px; background: linear-gradient(90deg, var(--blue), var(--green), var(--purple)); transform-origin: left; transform: scaleX(0); z-index: 199; }
  @media (max-width: 900px) { .progress-bar { left: 0; } }

  /* ===== HERO ===== */
  #hero { padding: 76px 48px 60px; max-width: 100%; text-align: center; }
  #cta  { padding: 60px 48px 76px; max-width: 100%; text-align: center; }

  .hero-badge { display: inline-block; background: rgba(79,168,255,0.1); border: 1px solid rgba(79,168,255,0.25); color: var(--blue); font-size: 11px; letter-spacing: 3px; text-transform: uppercase; padding: 6px 16px; border-radius: 20px; margin-bottom: 22px; font-family: 'JetBrains Mono', monospace; animation: fadeDown 0.6s ease both; }
  .hero-title { font-size: clamp(2.8rem, 8vw, 5rem); font-weight: 800; line-height: 1; background: linear-gradient(135deg, #4fa8ff 0%, #4dffb0 50%, #b87aff 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; animation: fadeDown 0.6s ease 0.1s both; }
  .hero-sub { font-size: 1rem; color: var(--muted); margin-top: 12px; font-family: 'JetBrains Mono', monospace; animation: fadeDown 0.6s ease 0.2s both; }
  .hero-code { display: inline-block; margin-top: 30px; background: #080810; border: 1px solid var(--border); border-radius: 14px; padding: 20px 28px; font-family: 'JetBrains Mono', monospace; font-size: 13px; line-height: 2; text-align: left; animation: fadeUp 0.6s ease 0.3s both; }
  .hero-buttons { display: flex; gap: 12px; justify-content: center; margin-top: 28px; flex-wrap: wrap; animation: fadeUp 0.6s ease 0.4s both; }
  .btn { padding: 11px 22px; border-radius: 10px; font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 700; text-decoration: none; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; border: none; display: inline-block; }
  .btn:hover { transform: translateY(-2px); }
  .btn-primary { background: var(--blue); color: #0d0d14; box-shadow: 0 4px 20px rgba(79,168,255,0.2); }
  .btn-outline  { background: transparent; color: var(--text); border: 1px solid var(--border); }
  .btn-outline:hover { border-color: var(--blue); color: var(--blue); }

  /* ===== SECTIONS ===== */
  section { padding: 68px 48px; max-width: 820px; }
  @media (max-width: 600px) { section { padding: 50px 20px; } #hero { padding: 56px 20px 44px; } #cta { padding: 44px 20px 60px; } }

  .section-label { font-size: 10px; letter-spacing: 3px; text-transform: uppercase; color: var(--muted); font-family: 'JetBrains Mono', monospace; margin-bottom: 10px; }
  .section-heading { font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 800; line-height: 1.15; margin-bottom: 12px; }
  .section-desc { color: var(--muted); font-size: 14px; line-height: 1.75; max-width: 580px; margin-bottom: 24px; }

  .divider { height: 1px; background: linear-gradient(90deg, transparent, var(--border), transparent); margin: 0 48px; }
  @media (max-width: 600px) { .divider { margin: 0 20px; } }

  .code-inline { font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--blue); background: rgba(79,168,255,0.08); padding: 2px 7px; border-radius: 5px; }

  .cta-box { background: linear-gradient(135deg, rgba(79,168,255,0.07), rgba(77,255,176,0.07)); border: 1px solid rgba(79,168,255,0.18); border-radius: 20px; padding: 50px 36px; max-width: 560px; margin: 0 auto; }
  .cta-title { font-size: clamp(1.5rem, 4vw, 2.4rem); font-weight: 800; margin-bottom: 12px; background: linear-gradient(135deg, var(--blue), var(--green)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
  .cta-text { color: var(--muted); font-size: 14px; line-height: 1.7; margin-bottom: 22px; }

  footer { border-top: 1px solid var(--border); padding: 22px 48px; text-align: center; font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--muted); position: relative; z-index: 1; }
  footer span { color: var(--blue); }

  .fade-in { opacity: 0; transform: translateY(18px); transition: opacity 0.55s ease, transform 0.55s ease; }
  .fade-in.visible { opacity: 1; transform: translateY(0); }

  .container {
    max-width: 860px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
  }

  /* Legacy header */
  .container{
    display: inline-block;
    background: rgba(79,168,255,0.12);
    border: 1px solid rgba(79,168,255,0.3);
    color: var(--blue);
    font-size: 12px;
    letter-spacing: 3px;
    text-transform: uppercase;
    padding: 6px 16px;
    border-radius: 20px;
    margin-bottom: 16px;
    font-family: 'JetBrains Mono', monospace;
  }

  h1 {
    font-size: clamp(2rem, 6vw, 3.5rem);
    font-weight: 800;
    line-height: 1.1;
    background: linear-gradient(135deg, #4fa8ff 0%, #4dffb0 50%, #b87aff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }

  .subtitle {
    color: var(--muted);
    margin-top: 10px;
    font-size: 1rem;
    font-family: 'JetBrains Mono', monospace;
  }

  .anatomy-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px;
    margin-bottom: 28px;
    animation: fadeUp 0.6s ease 0.1s both;
  }

  .section-title {
    font-size: 11px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--muted);
    font-family: 'JetBrains Mono', monospace;
    margin-bottom: 20px;
  }

  .section-footer {
    font-size: 11px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--muted);
    font-family: 'JetBrains Mono', monospace;
    margin-bottom: 20px;
    justify-content: center;
    align-items: center;
    display: flex;
    margin-top: 1rem;
  }

  .code-anatomy {
    background: #080810;
    border-radius: 12px;
    padding: 24px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 15px;
    line-height: 2;
  }

  .code-line {
    display: flex;
    align-items: center;
    position: relative;
  }

  .kw    { color: var(--pink);   font-weight: 700; }
  .fn    { color: var(--yellow); font-weight: 700; }
  .paren { color: var(--muted); }
  .param { color: var(--blue); }
  .op    { color: var(--muted); }
  .str   { color: var(--green); }
  .ret   { color: var(--purple); font-weight: 700; }
  .var   { color: var(--text); }
  .cmt   { color: #404060; font-style: italic; }
  .num   { color: var(--orange); }
  .indent { display: inline-block; width: 28px; }

  .annotations {
    margin-top: 24px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
  }

  .ann {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    font-size: 13px;
  }

  .ann-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 3px;
  }

  .ann-label { color: var(--muted); font-family: 'JetBrains Mono', monospace; font-size: 11px; margin-bottom: 2px; }
  .ann-desc  { color: var(--text); font-size: 12px; }

  .anatomy-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 28px;
    animation: fadeUp 0.6s ease 0.1s both;
  }

  @media (max-width: 600px) { .anatomy-split { grid-template-columns: 1fr; } }

  .anatomy-half {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
  }

  .levels-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 28px;
  }

  @media (max-width: 600px) { .levels-grid { grid-template-columns: 1fr; } }

  .level-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.2s;
    animation: fadeUp 0.6s ease both;
  }

  .level-card:nth-child(1) { animation-delay: 0.15s; }
  .level-card:nth-child(2) { animation-delay: 0.25s; }
  .level-card:nth-child(3) { animation-delay: 0.35s; }
  .level-card:nth-child(4) { animation-delay: 0.45s; }

  .level-card:hover { transform: translateY(-3px); }
  .level-card[data-color="blue"]:hover   { border-color: var(--blue); }
  .level-card[data-color="green"]:hover  { border-color: var(--green); }
  .level-card[data-color="pink"]:hover   { border-color: var(--pink); }
  .level-card[data-color="purple"]:hover { border-color: var(--purple); }

  .level-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
  }

  .level-num {
    width: 28px; height: 28px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px;
    font-family: 'JetBrains Mono', monospace;
  }

  .level-title { font-weight: 700; font-size: 14px; }

  .level-code {
    background: #080810;
    border-radius: 8px;
    padding: 14px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    line-height: 1.7;
  }

  .level-output {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--muted);
  }

  .output-arrow { color: var(--green); }

  .flow-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px;
    margin-bottom: 28px;
    animation: fadeUp 0.6s ease 0.5s both;
  }

  .flow-loop {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-top: 20px;
  }

  .flow-row {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .flow-box {
    padding: 12px 20px;
    border-radius: 10px;
    text-align: center;
    font-size: 13px;
    font-family: 'JetBrains Mono', monospace;
    min-width: 130px;
  }

  .flow-arrow-v {
    font-size: 20px;
    color: var(--muted);
    line-height: 1;
  }

  .flow-label {
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 4px;
  }

  .flow-value {
    font-weight: 700;
    font-size: 14px;
  }

  .loop-back {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    letter-spacing: 1px;
    margin-top: 4px;
  }

  .loop-back-line {
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, var(--blue), var(--purple));
    border-radius: 2px;
  }

  .compare-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px;
    margin-bottom: 28px;
    animation: fadeUp 0.6s ease 0.45s both;
  }

  .compare-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    margin-top: 4px;
  }

  .compare-table th {
    padding: 10px 16px;
    text-align: left;
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
  }

  .compare-table td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    vertical-align: top;
    line-height: 1.6;
  }

  .compare-table tr:last-child td { border-bottom: none; }

  .tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
  }

  .rule-card {
    background: linear-gradient(135deg, rgba(79,168,255,0.08), rgba(77,255,176,0.08));
    border: 1px solid rgba(79,168,255,0.25);
    border-radius: 14px;
    padding: 24px 28px;
    display: flex;
    align-items: center;
    gap: 16px;
    animation: fadeUp 0.6s ease 0.6s both;
  }

  .rule-icon { font-size: 28px; flex-shrink: 0; }
  .rule-text { font-size: 15px; line-height: 1.5; }
  .rule-text strong { color: var(--blue); }

  @keyframes fadeDown {
    from { opacity: 0; transform: translateY(-20px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  @keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
  }